﻿using CPPEI.Coolzon.UI.XProperty;
using CPPEI.Coolzon.UI.XProperty.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace CPPEI.Coolzon.UI.DataPartLib.XProperty.Converters
{
    public class XColumnsConverter : IPropertyValueConverter
    {
        public object Convert(ConvertContext context, Metadata.ValueNode valueNode)
        {
            List<CTColumn> ctColumns = new List<CTColumn>();
            foreach (Metadata.ValueNode vN in valueNode.ValueNodes)
            {
                CTColumn ctColumn = new CTColumn();
                ctColumn.Name = vN.Attributes["Name"];
                ctColumn.Caption = vN.Attributes["Caption"];
                ctColumn.DataItemId = vN.Attributes["DataItemId"];
                ctColumns.Add(ctColumn);
            }
            return ctColumns;
        }

        public Metadata.ValueNode ConvertBack(ConvertContext context, object value)
        {
            return null;
        }
    }
}
